package com.framework.base.util;

import java.io.IOException;
import java.util.Properties;

/**
 * @Copyright @ 2011 All right reserved
 * @version 创建时间：Created on 2011-5-17
 * @author 作者：Create by HYH
 * @Email: 517372264@qq.com
 * @description 用于获取各种系统属性
 * 
 */
public class SysConfUtil {
	public static Properties sysProperties;
	/**
	 * 获取升序图片路径
	 * @return
	 */
	public static String getOrderUpPath(){
		return getConfValue("list.orderup.path");
	}
	/**
	 * 获取倒序图片路径
	 * @return
	 */
	public static String getOrderDownPath(){
		return getConfValue("list.orderdown.path");
	}
	/**
	 * 获取系统通用密码
	 * 
	 * @return
	 */
	public static String getCommonPwd() {
		return getConfValue("commonPwd");
	}

	/**
	 * 用于获取上传路径
	 * 
	 * @return
	 */
	public static String getUpLoadPath() {
		return getConfValue("uploadPath");
	}
	/**
	 * 获取表单需要解析的标签 
	 * @return
	 */
	public static String getHtmlFormElementTags(){
		return getConfValue("htmlformelementtags");
	}
	/**
	 * 获取默认的每页大小
	 * 
	 * @return
	 */
	public static int getPageSize() {
		String value = getConfValue("page.rowsPerPage");
		if ("".equals(value)) {
			return 0;
		} else {
			return Integer.parseInt(value);
		}
	}
	/**
	 * 获取建设单位的名称
	 * @return
	 */
	public static String getBuildUnit(){
		return  getConfValue("buildunit");
	}

	/**
	 * 用于获取相应的值
	 * 
	 * @param key
	 * @return
	 */
	public static String getConfValue(String key) {
		if (sysProperties == null) {
			SysConfUtil.sysProperties = new Properties();
			try {
				SysConfUtil.sysProperties.load(SysConfUtil.class
						.getResourceAsStream("/system.properties"));
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		Object obj = sysProperties.get(key);
		if (obj == null) {
			return "";
		} else {
			return obj.toString();
		}
	}
}
